package servlet;

import dao.PersonDAO;
import dao.materialDAO;
import entity.PersonBean;
import entity.materialBean;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 王开心
 * @Date: 2024/04/21/21:49
 * @Description:
 */
@WebServlet("/group/material/material_edit")
public class MaterialEditServlet  extends HttpServlet {
    public MaterialEditServlet() {
        super();
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int r_id=Integer.parseInt(req.getParameter("r_id"));
        materialDAO dao = new materialDAO();
        materialBean editMaterialBean;

        editMaterialBean = dao.editMaterial(r_id);
        req.setAttribute("editMaterialBean",editMaterialBean);
        req.getRequestDispatcher("material_edit.jsp").forward(req, resp);
    }
}
